﻿using System.ComponentModel;
using Hopscotch.Presentation.Controls.Core;
using FluentAssertions;
using NUnit.Framework;

namespace Hopscotch.Presentation.Controls.Test
{
    [TestFixture, RequiresSTA]
    public class QuantityControlTest
    {
        private QuantityControl quantityControl;

        [SetUp]
        public void Setup()
        {
            quantityControl = new QuantityControl();
        }

        [Test]
        public void TestSettingQuantityRaisesValueChanged()
        {
            bool raised = false;
            DependencyPropertyDescriptor dpd = DependencyPropertyDescriptor
                .FromProperty(QuantityControl.QuantityProperty, typeof(QuantityControl));
            if (dpd != null)
            {
                dpd.AddValueChanged(quantityControl, (sender, e) => { raised = true; });
            }

            quantityControl.Quantity = 100;

            raised.Should().BeTrue();
        }
    }
}
